
* Replication of Fig. 1B-E 
* Vestby et al. (2023) "Societal Determinants of flood-induced displacement", PNAS
* https://doi.org/10.1073/pnas.2206188120
* All replication material stored at Harvard Dataverse, https://doi.org/10.7910/DVN/JMAP2M


use ../data/Fig1B-E_repdata.dta, clear
set scheme s1mono

* Fig 1B
twoway (area y_flood year, sort fcolor(navy))  ///
(line ly_avgdeath year, sort lcolor(orange) lwidth(thick) connect(stairstep) yaxis(2)), ///
ytitle("EM-DAT flood frequency", size(large) color(navy)) ytitle("Average flood mortality (ln)", size(large) color(orange) axis(2)) ///
ylabel(0(100)300, labsize(large) labcolor(navy)) ylabel(0(1)7, labsize(large) labcolor(orange) axis(2)) xtitle(Year, size(large)) ///
xlabel(, labsize(large)) legend(order(1 "Frequency" 2 "Mortality")) legend(off) xsize(5.5) ysize(4)

* Fig 1C
twoway (contour ldeathavg_dec gdp_dec year, scolor(white) ecolor(navy)) ///
if year>=1970 & gdp_dec!=. , ylabel(1(1)10) ylabel(, labsize(large)) ytitle("Income level (decile)", size(large)) ///
xtitle(Year, size(large)) xlabel(, labsize(large)) ztitle("Average flood mortality (ln)", size(large)) ///
zlabel(#5, labsize(large)) xsize(6) ysize(4)

* FIG 1D
twoway (area y_dfo_floods year, sort fcolor(navy))  ///
(line ly_dfo_avgdispl year, sort lcolor(orange) lwidth(thick) connect(stairstep) yaxis(2)) if year>=1985, ///
ytitle("DFO flood frequency", size(large) color(navy)) ytitle("Average flood displacements (ln)", size(large) color(orange) axis(2)) ///
ylabel(0(100)300, labsize(large) labcolor(navy)) ylabel(0(2)14, labsize(large) labcolor(orange) axis(2)) xtitle(Year, size(large)) ///
xlabel(1970(10)2020, labsize(large)) legend(off) xsize(5.5) ysize(4)

* Fig. 1E
twoway (contour ldfo_displ_dec gdp_dec year, scolor(white) ecolor(navy)) ///
if year>=1985 & gdp_dec!=. , ylabel(1(1)10) ylabel(, labsize(large)) ytitle("Income level (decile)", size(large)) ///
xtitle(Year, size(large)) xlabel(1970(10)2020, labsize(large)) ztitle("Average flood displacements (ln)", size(large)) ///
zlabel(0(3)15, labsize(large)) xsize(6) ysize(4)
